﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDxfDocument

{

    class FriedDoughTwists1
    {
        //图F.59  ISYC 306-01-带可转位刀麻花钻
        public static void FriedDoughTwists2(Dictionary<string, Object> data)  //  带可转位刀麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
          //  double sl_ = Convert.ToDouble(data["oal"]);
          //  double scale = Convert.ToDouble(data["scale"]);
            double sl_ = 45;
            double scale = 1;
            if (sl_ <= 67)
            {
                scale = 4;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 2.5;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 2;
            }
            else
            {
                scale = 1;
            }
            
            double ls = 30*scale ;
            double lpr = 45 * scale;
            double oal = 75 * scale;
            double dconms = 20 * scale;
            double dc = 15 * scale;
            double lcf = 39 * scale;
            double lu = 34 * scale;

            double sig = 150;
            double fha = 15;
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;
            /*
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;           
            double sig = Convert.ToDouble(data["sig"]);
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;*/
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = fun.Polar(p0, 0, 5);
            Vector2 p0_2 = fun.Polar(p0, pi, oal + 5);
            Vector2 p1 = fun.Polar(p0, pi / 2, dconms / 2);
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 p3 = fun.Polar(p1, pi / -4, Math.Sqrt(2) * dconms / 20.0);
            Vector2 p4 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p5 = fun.Polar(p1, pi, ls - dconms / 20.0 * 2);
            Vector2 p6 = fun.mirrorpoint(p5, p0_1, p0_2);
            Vector2 p7 = fun.Polar(p5, pi / -2,  dconms / 20.0);
            Vector2 p8 = fun.mirrorpoint(p7, p0_1, p0_2);
            Vector2 p9 = fun.Polar(p7, pi, dconms / 20.0 * 2);
            Vector2 p10 = fun.Polar(p8, pi, dconms / 20.0 * 2);
            Vector2 p11 = fun.Polar(p9, pi / 2, fun.CalDistance(p5, p7)*2);
            Vector2 p12 = fun.mirrorpoint(p11, p0_1, p0_2);
            Vector2 p13 = fun.Polar(p11, pi, lpr * (1.5 / 37.35));
            Vector2 p14 = fun.mirrorpoint(p13, p0_1, p0_2);
            Vector2 p15 = fun.Polar(p11, pi / -2, fun.CalDistance(p11, p13) * 2);
            Vector2 p16 = fun.mirrorpoint(p15, p0_1, p0_2);
            Vector2 p17 = fun.Polar(p15, pi, fun.CalDistance(p11, p13));
            Vector2 p18 = fun.mirrorpoint(p17, p0_1, p0_2);
            Vector2 p18_1 = fun.Polar(p11, pi, (lpr - lcf) / (3.0 / 2.0)) ;
            Vector2 p18_2 = fun.Polar(p18_1, pi / -2-0.1*pi/180, oal);
            Vector2 p19 = fun.Polar(p15, pi, lpr - lcf);
            Vector2 p20 = fun.mirrorpoint(p19, p0_1, p0_2);
            Vector2 p19_1 = fun.Polar(p15, pi / -2, 0.1);
            Vector2 p19_2 = fun.Polar(p19_1, pi, oal);
            Vector2 p20_1 = fun.mirrorpoint(p19_1, p0_1, p0_2);
            Vector2 p20_2 = fun.mirrorpoint(p19_2, p0_1, p0_2);
            Vector2 p21 = fun.Polar(p20, pi - 15 * pi / 180, (lcf - lu) / Math.Cos(fha_));
            Vector2 p21_1 = fun.Polar(p20, pi / 2, 0.1);
            Vector2 p21_2 = fun.Polar(p21_1, pi - fha_*2, oal);
            Vector2 p22_0 = fun.Polar(p0, pi, oal);
            Vector2 p22 = fun.Polar(p22_0, pi / -2, dc / 2.0 / 4.0);
            Vector2 p23 = fun.Polar(p22, sig_ / -2, dc / 5.0);
            Vector2 p24 = fun.Polar(p22, sig_ / 2, dc / 5.0);
            Vector2 p24_0 = fun.Polar(p22_0, pi / 2, dc / 2.0);
            Vector2 p25 = fun.Polar(p24_0, pi / -2, dc / 5.0);
            Vector2 p26_1 = fun.Polar(p24_0, 0, oal);
            Vector2 p26_2 = fun.Polar(p25, 150 / 2 * pi / 180, oal);
            Vector2 p26 = fun.Inters(p25, p26_2, p24_0, p26_1);
            Vector2 p27 = fun.Polar(p26, fun.CalAngle(p26, p25) + pi / 2, fun.CalDistance(p25, p26));
            Vector2 p28 = fun.Polar(p27, fun.CalAngle(p27, p26) + 150 * pi / 180, fun.CalDistance(p25, p26));
            Vector2 p29 = fun.Polar(p28, fun.CalAngle(p28, p27) + pi / 2, fun.CalDistance(p25, p26));
            Vector2 p30 = fun.Polar(p29, fun.CalAngle(p29, p28) + 150 * pi / 180, fun.CalDistance(p25, p26));
            Vector2 p31 = fun.Polar(p30, fun.CalAngle(p30, p29), fun.CalDistance(p30, p29) * (0.2 / 3.1));
            Vector2 p32_1 = fun.Polar(p31, fun.CalAngle(p25, p30), oal);
            Vector2 p32_2 = fun.Polar(p24, pi / -2, dc / 10.0);
            Vector2 p32_3 = fun.Polar(p32_2, 0, oal);
            Vector2 p32 = fun.Inters(p31, p32_1, p32_2, p32_3);
            Vector2 p33_1 = fun.Polar(p23, fun.CalAngle(p23, p22), fun.CalDistance(p23, p22) / 6.0);
            Vector2 p33_2 = fun.Polar(p33_1, pi, oal);
            Vector2 p33_3 = fun.Polar(p32, pi/-2, oal);
            Vector2 p33 = fun.Inters(p32, p33_3, p32_1, p32_2);
            Vector2 p34_0 = fun.Polar(p22, pi, oal);
            Vector2 p34 = fun.Inters(p22, p34_0, p32, p33);
            Vector2 p35_0 = fun.Polar(p24, fun.CalAngle(p24, p22) - pi / 2, oal);
            Vector2 p35 = fun.Inters(p24, p35_0, p31, p32);
            Vector2 p36_1 = fun.Polar(p22_0, pi / -2, dc / 2.0);
            Vector2 p36_2 = fun.Polar(p36_1, pi, oal);
            Vector2 p36_3 = fun.Polar(p32, pi / -2, oal);
            Vector2 p36 = fun.Inters(p36_1, p36_2, p33, fun.Polar(p33, pi / -2 - ((fun.CalAngle(p32, p33) - fun.CalAngle(p32, p36_3))/2),oal ));
            Vector2 p37_0 = fun.Polar(p23, fun.CalAngle(p22, p23) + pi / 2, oal);
            Vector2 p37 = fun.Inters(p23, p37_0, p33, p36);
            Vector2 p38_1 = fun.Polar(p22_0, pi / 2, dc/2 - dc / 30.0);
            Vector2 p38_2 = fun.Polar(p38_1, 0, oal);
            Vector2 p38 = fun.Inters(p26, p27, p38_1, p38_2);
            Vector2 p39 = fun.Polar(p38, 0, lpr / 6.0);
            Vector2 p40_1 = fun.Polar(p39, pi / -2, oal);
            Vector2 p40_2 = fun.Polar(p36, 0, oal);
            Vector2 p40 = fun.Inters(p39, p40_1, p36, p40_2);
            Vector2 p41=fun .Polar (p39,pi/-4,Math .Sqrt (2)*(dc/20.0));
            Vector2 p42 = fun.mirrorpoint(p41, p0_1, p0_2);
            Vector2 p43 = fun.Polar(p32, 0, fun.CalDistance(p34, p22));
            Vector2 p43_1 = fun.Polar(p19, pi / 2, 0.1);
            Vector2 p43_2 = fun.Polar(p43_1, pi + fha_ / 4, oal);
            Vector2 p43_3 = fun.Polar(p40, fun.CalAngle(p40, p42), fun.CalDistance(p40, p42) / 2.0);
            Vector2 p43_4 = fun.Polar(p43_3, 0, oal);
            Vector2 p44_0 = fun.Polar(p39, pi / -4, oal);
            Line line5 = new Line(p43_1, p43_2);
            Arc arc5 = fun.DrawArc5(p19, line5, p43);
            Vector2 p44 = fun.Inters1(p39, p44_0, arc5,0);
            Vector2 p45_1 = fun.Polar(p39, pi, 0.1);
            Vector2 p45_2 = fun.Polar(p45_1, -50*pi/180, oal);
            Vector2 p45_3 = fun.Polar(p40, pi / 2+0.01*pi/180, oal);
            Vector2 p45 = fun.Inters1(p40, p45_3, arc5, 0);
            Vector2 p46_0 = fun.Polar(p39, -fha_ - 5 * pi / 180, oal);
            Line line6 = new Line(p43_3, p43_4);
            Arc arc6 = fun.DrawArc5(p42, line6, p21);           
            Vector2 p46_1 = fun.Polar(p20, pi / -2, 0.1);
            Vector2 p46_2 = fun.Polar(p46_1, fun.CalAngle(p20, p23), oal);
            Vector2 p46 = fun.Inters1(p20, p23, arc6, 1);
            Vector2 p47 = fun.Polar(p33, 0, fun.CalDistance(p32, p43) / 1.5);
            Vector2 p47_1 = fun.Polar(p36, 0, 0.1);
            Vector2 p47_2 = fun.Polar(p47_1, pi / 2 - fha_*2, oal);
            Vector2 p47_3 = fun.Polar(p47_1, pi / 2 - fha_, oal);
            Vector2 p48_0 = fun.Polar(p46, pi / 2+0.01*pi/180, oal);
            Vector2 p48 = fun.Inters1(p46, p48_0, arc5, 0);
            Vector2 p48_1 = fun.Polar(p41, pi / 2, 0.1);
            Vector2 p48_2 = fun.Polar(p48_1, fha_ / -4, oal);

            
                Vector2 p50 = fun.Polar(p22_0, pi / -2, oal * 1.5);
            Vector2 p50_1 = fun.Polar(p50, pi, 5);
            Vector2 p50_2 = fun.Polar(p50, 0, lu * 3 / 1.5);
                Vector2 p51 = fun.Polar(p50, fun.CalAngle(p22_0, p22), fun.CalDistance(p22_0, p22) * 3);
                Vector2 p52 = fun.Polar(p51, fun.CalAngle(p22, p23), fun.CalDistance(p22, p23) * 3);
                Vector2 p53 = fun.Polar(p51, fun.CalAngle(p22, p24), fun.CalDistance(p22, p24) * 3);
                Vector2 p54= fun.Polar(p53, fun.CalAngle(p24, p25), fun.CalDistance(p24, p25) * 3);
                Vector2 p55= fun.Polar(p54, fun.CalAngle(p25, p26), fun.CalDistance(p25, p26) * 3);
                Vector2 p56= fun.Polar(p55, fun.CalAngle(p26, p27), fun.CalDistance(p26, p27) * 3);
                Vector2 p57= fun.Polar(p56, fun.CalAngle(p27, p28), fun.CalDistance(p27, p28) * 3);
                Vector2 p58= fun.Polar(p57, fun.CalAngle(p28, p29), fun.CalDistance(p28, p29) * 3);
                Vector2 p59= fun.Polar(p58, fun.CalAngle(p29, p30), fun.CalDistance(p29, p30) * 3);
                Vector2 p60= fun.Polar(p59, fun.CalAngle(p30, p31), fun.CalDistance(p30, p31) * 3);
                Vector2 p61 = fun.Polar(p60, fun.CalAngle(p31, p32), fun.CalDistance(p31, p32)*3);
                Vector2 p62= fun.Polar(p61, fun.CalAngle(p32, p33), fun.CalDistance(p32 , p33) * 3);
                Vector2 p63= fun.Polar(p51, fun.CalAngle(p22, p34), fun.CalDistance(p22, p34) * 3);
                Vector2 p64= fun.Polar(p53, fun.CalAngle(p24, p35), fun.CalDistance(p24, p35)*3 );
                Vector2 p65= fun.Polar(p62, fun.CalAngle(p33, p36), fun.CalDistance(p33, p36) * 3);
                Vector2 p66= fun.Polar(p65, fun.CalAngle(p36, p37), fun.CalDistance(p36, p37) * 3);
                Vector2 p67= fun.Polar(p55, fun.CalAngle(p26, p38), fun.CalDistance(p26, p38) * 3);
                Vector2 p68= fun.Polar(p67, fun.CalAngle(p38, p39), fun.CalDistance(p38, p39) * 3);
                Vector2 p69= fun.Polar(p65, fun.CalAngle(p36, p40), fun.CalDistance(p36, p40) * 3);
                Vector2 p70= fun.Polar(p68, fun.CalAngle(p39, p41), fun.CalDistance(p39, p41) * 3);
                Vector2 p71= fun.Polar(p69, fun.CalAngle(p40, p42), fun.CalDistance(p40, p42) * 3);
                Vector2 p72= fun.Polar(p61, fun.CalAngle(p32, p43), fun.CalDistance(p32, p43) * 3);
                Vector2 p73= fun.Polar(p70, fun.CalAngle(p41, p44), fun.CalDistance(p41, p44) * 3);
                Vector2 p74= fun.Polar(p69, fun.CalAngle(p40, p45), fun.CalDistance(p40, p45) * 3);
                Vector2 p75= fun.Polar(p62, fun.CalAngle(p33, p47), fun.CalDistance(p33, p47) * 3);
                Vector2 p76= fun.Polar(p70, fun.CalAngle(p41, p48), fun.CalDistance(p41, p48) * 3);
                Vector2 p77 = fun.Polar(p71, fun.CalAngle(p42, p21), fun.CalDistance(p42, p21) * 3);
            Vector2 p78 = fun.Polar(p73, 0, (p76.X - p73.X) / 2.0);
            Vector2 p79 = fun.Polar(p78, pi / 2, oal );
            Vector2 p80 = fun.Polar(p78, pi / -2, oal );

            var polyline4 = Pus.AddPointsToLwPolyLine(p59, p54, p55, p67, p68, p70, p68, p67, p56, p57, p58, p59, p60, p61
                , p72, p61, p63, p51, p63, p62, p75, p62, p66, p52, p66, p65, p69, p74, p69, p71);
                var polyline5 = Pus.AddPointsToLwPolyLine(p52, p51, p53, p64);
            
            Line line1 = new Line(p18_1, p18_2);
            Line line2 = new Line(p19_1, p19_2);
            Line line3 = new Line(p20_1, p20_2);
            Line line4 = new Line(p21_1, p21_2);
            Line line7 = new Line(p45_1, p45_2);
            Line line8 = new Line(p46_1, p46_2);
            Line line9 = new Line(p47_1, p47_2);
            Line line10 = new Line(p47_1, p47_3);
            Line line11 = new Line(p48_1, p48_2);



            var polyline1 = Pus.AddPointsToLwPolyLine(p1, p2, p4, p3, p1, p5,p7,p9,p7, p6,p2,p6, p8, p10, p11
            , p12, p14, p18, p16, p15, p17, p13, p11);
            var polyline2 = Pus.AddPointsToLwPolyLine(p23, p22, p24,p35);
            var polyline3 = Pus.AddPointsToLwPolyLine(p30,p25,p26,p38,p39,p41,p39,p38,p27,p28,p29,p30,p31,p32
                ,p43,p32,p34,p22,p34,p33,p47,p33,p37,p23,p37,p36,p40,p45,p40,p42);
            Arc arc1 = fun.DrawArc5(p17, line1, p18);
            Arc arc2 = fun.DrawArc5(p19, line2, p13);
            Arc arc3 = fun.DrawArc5(p14, line3, p20);
            Arc arc4 = fun.DrawArc5(p20, line4, p21);    
            Arc arc7 = fun.DrawArc5(p41, line7, p44);
            Arc arc8 = fun.DrawArc5(p46, line8, p20);
            Arc arc9 = fun.DrawArc5(p36, line9, p47);  
            Arc arc10 = fun.DrawArc5(p47, line10, p43);
            Arc arc11 = fun.DrawArc5(p48, line11, p41);
            Arc arc12 = fun.DrawArc4(p75, arc10.Radius*3, p72, 0);
            Arc arc13 = fun.DrawArc4(p65, arc9.Radius*3, p75, 0);
            Arc arc14 = fun.DrawArc3(p73, p74, p72);
            Arc arc15 = fun.DrawArc4(p70, arc7.Radius * 3, p73, 0);
            Arc arc16 = fun.DrawArc4(p76, arc11.Radius*3, p70, 0);//
            Arc arc17 = fun.DrawArc3(p76, p73, p74); //
            Arc arc18 = fun.DrawArc4(p71, arc6.Radius * 3, p77, 0);//
            Vector2 p81 = fun.Inters1(p79, p80, arc16, 1);
            Vector2 p82 = fun.Inters1(p79, p80, arc17, 1);
            Vector2 p83 = fun.Inters1(p79, p80, arc18, 0);
            Vector2 p88_ = fun.Inters(p81, fun.Polar(p81, pi / -2, oal), p50, fun.Polar(p50, 0, oal * 3));
            Arc arc19 = fun.DrawArc4(p81, arc16.Radius, p70, 0);
            Arc arc20 = fun.DrawArc4(p82, arc17.Radius, p74, 0);
            Arc arc21 = fun.DrawArc4(p71, arc18.Radius, p83, 0);
            Vector2 p84 = fun.Polar(p81, pi, 0.1);
            Vector2 p85 = fun.Polar(p84, -130 * pi / 180, oal);
            Vector2 p88 = fun.Polar(p82, 0, 0.1);
            Vector2 p89 = fun.Polar(p88, -50 * pi / 180, oal);
            Vector2 p90 = fun.Polar(p88_, pi, 0.1*3);
            Vector2 p91 = fun.Polar(p90, -133 * pi / 180, oal);
            Line line12 = new Line(p84, p85);
            Line line14 = new Line(p89, p88);
            Line line15 = new Line(p90, p91);
            Arc arc22 = fun.DrawArc5(p81, line12, p82);
            Vector2 p86 = fun.Polar(p82, pi, 0.1);
            Vector2 p87 = fun.Polar(p86, -130 * pi / 180, oal);
            Line line13 = new Line(p86, p87);
            Arc arc23 = fun.DrawArc5(p88_, line14, p82);
            Arc arc24 = fun.DrawArc5(p88_, line15, p83);
            dxf.AddEntity(new EntityObject[] { polyline1,polyline2 ,polyline3 ,polyline4 ,polyline5 
            ,arc1 ,arc2,arc3,arc4,arc5,arc6,arc7,arc8,arc9,arc10,arc11,arc12,arc13,arc14,arc15,arc19
             ,arc20,arc21,arc22,arc23,arc24
            });
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);

            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc13, 0.5, contour);
            fun.drawBArc(dxf, arc14, 0.5, contour);
            fun.drawBArc(dxf, arc15, 0.5, contour);
            fun.drawBArc(dxf, arc19, 0.5, contour);
            fun.drawBArc(dxf, arc20, 0.5, contour);
            fun.drawBArc(dxf, arc21, 0.5, contour);
            fun.drawBArc(dxf, arc22, 0.5, contour);
            fun.drawBArc(dxf, arc23, 0.5, contour);
            fun.drawBArc(dxf, arc24, 0.5, contour);
            fun.PolyFill(dxf, polyline1, 0.5, contour);
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline3, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.PolyFill(dxf, polyline5, 0.5, contour);



            //标注
            //22_0刀尖
            
            Vector2 v1 = fun.Polar(p5, 0, ls / 10.0);
            Vector2 v2 = fun.Polar(v1, pi / 4, dc / 2.0);
            Vector2 v3 = fun.Polar(v2, pi / 4, dc / 2.0);
            Vector2 v4 = fun.Polar(p13, pi, dc / 2.0);
            Vector2 v5 = fun.Polar(v4, 0, fun.CalDistance(v4, p11) / 10);
            Vector2 v6 = fun.Polar(v5, pi / 2+0.01*pi/180, dc / 4.0);
            Vector2 v7 = fun.Polar(v6, pi / 2+0.01*pi/180, dc / 4.0);
            Vector2 v8 = fun.Polar(p24, pi + pi / 4, dconms*2.5);
            Vector2 v9 = fun.Polar(v8, 0, dc / 2.0);
            Vector2 v10 = fun.Polar(v9, 0, dc / 2.0);
            Vector2 v11 = fun.Polar(p4, pi / -4, dconms);
            Vector2 v12 = fun.Polar(p15, pi / -2, fun.CalDistance(p15, p16) / 2.0);
            Vector2 v13 = fun.Polar(p22_0, pi / 2 + 10 * pi / 180, 0.5*scale *1.7);
            Vector2 v14 = fun.Polar(v13, pi / 2 + 10 * pi / 180, dconms * 1.3);
            Vector2 v15 = fun.Polar(p26, pi / 4, 0.5 * scale * 1.7) ;
            Vector2 v16 = fun.Polar(v15, pi / 4, dc / 2.0);
            Vector2 v17 = fun.Polar(v12, pi / -4, 0.5*1.7*scale );
            Vector2 v18 = fun.Polar(v17, pi / -4, dconms);
            Vector2 v19 = fun.Polar(v18, pi / -2, 1.2 * scale);
            Vector2 v20 = fun.Polar(p54, pi / 2, dc*3/1.7);
            Vector2 v21 = fun.Polar(v20, pi / -2, fun.CalDistance(v20, p54)/10.0);
            Vector2 v22 = fun.Polar(v21, 0, dconms/4.0);
            Vector2 v23 = fun.Polar(v22, 0, dconms/4.0);
            Vector2 v24 = fun.Polar(p55, 15 * pi / 180, 0.5*1.7*scale );
            Vector2 v25 = fun.Polar(v24, 15 * pi / 180, dc * 3 /4.0);
            Vector2 v26 = fun.Polar(p50, pi + sig_ / 2, 0.5 * 1.7 * scale);
            Vector2 v27 = fun.Polar(v26, pi + sig_ / 2, dc * 3 / 1.5);
            Vector2 v28 = fun.Polar(v27, pi / -2, 1.2 * scale);
            Vector2 v29 = fun.Polar(p26, pi / 2, dc / 10.0);
            Vector2 v30 = fun.Polar(v29, pi, dc / 10.0);
            Vector2 v31 = fun.Polar(v30, pi / -2, dc + dc / 10.0*2);
            Vector2 v32 = fun.Polar(v31, 0, fun.CalDistance(p36, p40) + dc / 10.0*2);
            Vector2 v33 = fun.Polar(v32, pi / 2, fun.CalDistance(v30, v31)) ;
            Vector2 v34 = fun.Polar(p11, pi / 2, dc * 2);
            fun.dimrot1(dxf, p22_0 , fun .Polar (p22_0,0,lu), 180, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LU", "", "");
            fun.dimrot1(dxf, p22_0, p20 , 180, dc*1.5+p20.Y/2.0 , 2, 1.2 * scale, 1.6 * scale, 0.9, "LCF", "", "");
            fun.dimrot1(dxf, p22_0, fun.Polar(p22_0, 0, lpr ), 180, dc*2, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, p22_0, fun.Polar(p22_0, 0, oal ), 180, dc*2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p2 , p12 , 180, dc*1.5+(p12.Y -p2.Y )/2.0+p2.Y , 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p26,p36, 90, dc , 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p26, p11,0, dc , 2, 1.2 * scale, 1.6 * scale, 0.9, "LTA,LF", "", "");
            fun.dimrot1(dxf, p1, p2, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p25, p26, 0, dc + ((p11.Y - p25.Y) / 2.0 ), 2, 1.2 * scale, 1.6 * scale, 0.9, "PL", "", "");
            fun.dimrot1(dxf, p55, p54, 0, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LTA,LF,PL", "", "");
            fun.dimrot1(dxf, p55, p65, 90, dc , 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.Singlelinearrow(dxf, "CCMS", v1, 45, v2 , v3, 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "DF", v5, 90, v6, v7, 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "FDP", v8 , 180, v9, v10, 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "OAL", v21, 180, v22, v23, 1.2 * scale, 1.6 * scale);

            fun.Axis(dxf, v11,0, -90, "Z", "X", "Y", 0.5 * scale, 1.2 * scale, 0);
            fun.Axis(dxf, v12, 0, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
            fun.Axis(dxf, p22_0 ,0, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
            fun.Axis(dxf, p50 , 0, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);

            Line linev1 = new Line(p11, v4);
            Line linev2 = new Line(v14, v13);
            Line linev3 = new Line(v15, p16);
            Line linev4 = new Line(v17, v18);
            Line linev5 = new Line(p54, v20);
            Line linev6 = new Line(v24, v25);
            Line linev7 = new Line(v26, v27);
            Line linev8 = new Line(v16, v15);
            Line linev9 = new Line(v30, v31);
            linev9.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev9.Layer = additionalline;//Layer指图层
            linev9.LinetypeScale = 5 * scale;//指线性比例
            linev9.Linetype = Linetype.Dashed ;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev9); //提取

            Line linev10 = new Line(v32, v31);
            linev10.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev10.Layer = additionalline;//Layer指图层
            linev10.LinetypeScale = 5 * scale;//指线性比例
            linev10.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev10); //提取
            Line linev11 = new Line(v32, v33);
            linev11.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev11.Layer = additionalline;//Layer指图层
            linev11.LinetypeScale = 5 * scale;//指线性比例
            linev11.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev11); //提取
            Line linev12 = new Line(v33, v30);
            linev12.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev12.Layer = additionalline;//Layer指图层
            linev12.LinetypeScale = 5 * scale;//指线性比例
            linev12.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev12); //提取

            Line linev13 = new Line(p0_1 , p0_2 );
            linev13.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev13.Layer = center;//Layer指图层
            linev13.LinetypeScale = 5 * scale;//指线性比例
            linev13.Linetype = Linetype.DashDot ;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev13); //提取

            Line linev14 = new Line(p50_1 , p50_2 );
            linev14.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev14.Layer = center;//Layer指图层
            linev14.LinetypeScale = 5 * scale;//指线性比例
            linev14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev14); //提取
            Text txt1 = new Text("CIP", v14, 1.2 * scale, 0);
            Text txt2 = new Text("CRP", v16, 1.2 * scale, 0);
            Text txt3 = new Text("PCS,MCS", v19, 1.2 * scale, 0);
            Text txt4 = new Text("CRP", v25, 1.2 * scale, 0);
            Text txt5 = new Text("CIP", v28, 1.2 * scale, 0);
            Text txt6 = new Text("ISYC=306_01", v34, 1.2 * scale, 0);
            dxf.AddEntity(new EntityObject[] { linev1,linev2 ,linev3 ,linev4 ,linev5,linev6 ,linev7,linev8  
            ,txt1 ,txt2,txt3,txt4 ,txt5 ,txt6
            });
            fun.jdbz2(dxf, new Line(p23, p22), new Line(p24, p22), dc*1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");
            fun.jdbz2(dxf, new Line(p52, p51), new Line(p55, p54), dc*2, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        //图F.59  ISYC 306-01-带可转位刀麻花钻
        public static void ISYC_306_01(Dictionary<string, Object> data)  //  带可转位刀麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层         
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线           
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线           
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double sl_ = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
         //   double sl_ = 45;
        //    double scale = 1;
            if (sl_ <= 67)
            {
                scale = 4;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 2.5;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 2;
            }
            else
            {
                scale = 1;
            }
            /*
            double ls = 30 * scale;
            double lpr = 45 * scale;
            double oal = 75 * scale;
            double dconms = 20 * scale;
            double dc = 15 * scale;
            double lcf = 39 * scale;
            double lu = 34 * scale;
            
            double sig = 150;
            double fha = 15;
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;
            */
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;           
            double sig = Convert.ToDouble(data["sig"]);
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = fun.Polar(p0, 0, 5);
            Vector2 p0_2 = fun.Polar(p0, pi, oal + 5);
            Vector2 p1 = fun.Polar(p0, pi / 2, dconms / 2);
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 p3 = fun.Polar(p1, pi / -4, Math.Sqrt(2) * dconms / 20.0);
            Vector2 p4 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p5 = fun.Polar(p1, pi, ls - dconms / 20.0 * 2);
            Vector2 p6 = fun.mirrorpoint(p5, p0_1, p0_2);
            Vector2 p7 = fun.Polar(p5, pi / -2, dconms / 20.0);
            Vector2 p8 = fun.mirrorpoint(p7, p0_1, p0_2);
            Vector2 p9 = fun.Polar(p7, pi, dconms / 20.0 * 2);
            Vector2 p10 = fun.Polar(p8, pi, dconms / 20.0 * 2);
            Vector2 p11 = fun.Polar(p9, pi / 2, fun.CalDistance(p5, p7) * 2);
            Vector2 p12 = fun.mirrorpoint(p11, p0_1, p0_2);
            Vector2 p13 = fun.Polar(p11, pi, lpr * (1.5 / 37.35));
            Vector2 p14 = fun.mirrorpoint(p13, p0_1, p0_2);
            Vector2 p15 = fun.Polar(p11, pi / -2, fun.CalDistance(p11, p13) * 2);
            Vector2 p16 = fun.mirrorpoint(p15, p0_1, p0_2);
            Vector2 p17 = fun.Polar(p15, pi, fun.CalDistance(p11, p13));
            Vector2 p18 = fun.mirrorpoint(p17, p0_1, p0_2);
            Vector2 p18_1 = fun.Polar(p11, pi, (lpr - lcf) / (3.0 / 2.0));
            Vector2 p18_2 = fun.Polar(p18_1, pi / -2 - 0.1 * pi / 180, oal);
            Vector2 p19 = fun.Polar(p15, pi, lpr - lcf);
            Vector2 p20 = fun.mirrorpoint(p19, p0_1, p0_2);
            Vector2 p19_1 = fun.Polar(p15, pi / -2, 0.1);
            Vector2 p19_2 = fun.Polar(p19_1, pi, oal);
            Vector2 p20_1 = fun.mirrorpoint(p19_1, p0_1, p0_2);
            Vector2 p20_2 = fun.mirrorpoint(p19_2, p0_1, p0_2);
            Vector2 p21 = fun.Polar(p20, pi - 15 * pi / 180, (lcf - lu) / Math.Cos(fha_));
            Vector2 p21_1 = fun.Polar(p20, pi / 2, 0.1);
            Vector2 p21_2 = fun.Polar(p21_1, pi - fha_ * 2, oal);
            Vector2 p22_0 = fun.Polar(p0, pi, oal);
            Vector2 p22 = fun.Polar(p22_0, pi / -2, dc / 2.0 / 4.0);
            Vector2 p23 = fun.Polar(p22, sig_ / -2, dc / 5.0);
            Vector2 p24 = fun.Polar(p22, sig_ / 2, dc / 5.0);
            Vector2 p24_0 = fun.Polar(p22_0, pi / 2, dc / 2.0);
            Vector2 p25 = fun.Polar(p24_0, pi / -2, dc / 5.0);
            Vector2 p26_1 = fun.Polar(p24_0, 0, oal);
            Vector2 p26_2 = fun.Polar(p25, 150 / 2 * pi / 180, oal);
            Vector2 p26 = fun.Inters(p25, p26_2, p24_0, p26_1);
            Vector2 p27 = fun.Polar(p26, fun.CalAngle(p26, p25) + pi / 2, fun.CalDistance(p25, p26));
            Vector2 p28 = fun.Polar(p27, fun.CalAngle(p27, p26) + 150 * pi / 180, fun.CalDistance(p25, p26));
            Vector2 p29 = fun.Polar(p28, fun.CalAngle(p28, p27) + pi / 2, fun.CalDistance(p25, p26));
            Vector2 p30 = fun.Polar(p29, fun.CalAngle(p29, p28) + 150 * pi / 180, fun.CalDistance(p25, p26));
            Vector2 p31 = fun.Polar(p30, fun.CalAngle(p30, p29), fun.CalDistance(p30, p29) * (0.2 / 3.1));
            Vector2 p32_1 = fun.Polar(p31, fun.CalAngle(p25, p30), oal);
            Vector2 p32_2 = fun.Polar(p24, pi / -2, dc / 10.0);
            Vector2 p32_3 = fun.Polar(p32_2, 0, oal);
            Vector2 p32 = fun.Inters(p31, p32_1, p32_2, p32_3);
            Vector2 p33_1 = fun.Polar(p23, fun.CalAngle(p23, p22), fun.CalDistance(p23, p22) / 6.0);
            Vector2 p33_2 = fun.Polar(p33_1, pi, oal);
            Vector2 p33_3 = fun.Polar(p32, pi / -2, oal);
            Vector2 p33 = fun.Inters(p32, p33_3, p32_1, p32_2);
            Vector2 p34_0 = fun.Polar(p22, pi, oal);
            Vector2 p34 = fun.Inters(p22, p34_0, p32, p33);
            Vector2 p35_0 = fun.Polar(p24, fun.CalAngle(p24, p22) - pi / 2, oal);
            Vector2 p35 = fun.Inters(p24, p35_0, p31, p32);
            Vector2 p36_1 = fun.Polar(p22_0, pi / -2, dc / 2.0);
            Vector2 p36_2 = fun.Polar(p36_1, pi, oal);
            Vector2 p36_3 = fun.Polar(p32, pi / -2, oal);
            Vector2 p36 = fun.Inters(p36_1, p36_2, p33, fun.Polar(p33, pi / -2 - ((fun.CalAngle(p32, p33) - fun.CalAngle(p32, p36_3)) / 2), oal));
            Vector2 p37_0 = fun.Polar(p23, fun.CalAngle(p22, p23) + pi / 2, oal);
            Vector2 p37 = fun.Inters(p23, p37_0, p33, p36);
            Vector2 p38_1 = fun.Polar(p22_0, pi / 2, dc / 2 - dc / 30.0);
            Vector2 p38_2 = fun.Polar(p38_1, 0, oal);
            Vector2 p38 = fun.Inters(p26, p27, p38_1, p38_2);
            Vector2 p39 = fun.Polar(p38, 0, lpr / 6.0);
            Vector2 p40_1 = fun.Polar(p39, pi / -2, oal);
            Vector2 p40_2 = fun.Polar(p36, 0, oal);
            Vector2 p40 = fun.Inters(p39, p40_1, p36, p40_2);
            Vector2 p41 = fun.Polar(p39, pi / -4, Math.Sqrt(2) * (dc / 20.0));
            Vector2 p42 = fun.mirrorpoint(p41, p0_1, p0_2);
            Vector2 p43 = fun.Polar(p32, 0, fun.CalDistance(p34, p22));
            Vector2 p43_1 = fun.Polar(p19, pi / 2, 0.1);
            Vector2 p43_2 = fun.Polar(p43_1, pi + fha_ / 4, oal);
            Vector2 p43_3 = fun.Polar(p40, fun.CalAngle(p40, p42), fun.CalDistance(p40, p42) / 2.0);
            Vector2 p43_4 = fun.Polar(p43_3, 0, oal);
            Vector2 p44_0 = fun.Polar(p39, pi / -4, oal);
            Line line5 = new Line(p43_1, p43_2);
            Arc arc5 = fun.DrawArc5(p19, line5, p43);
            Vector2 p44 = fun.Inters1(p39, p44_0, arc5, 0);
            Vector2 p45_1 = fun.Polar(p39, pi, 0.1);
            Vector2 p45_2 = fun.Polar(p45_1, -50 * pi / 180, oal);
            Vector2 p45_3 = fun.Polar(p40, pi / 2 + 0.01 * pi / 180, oal);
            Vector2 p45 = fun.Inters1(p40, p45_3, arc5, 0);
            Vector2 p46_0 = fun.Polar(p39, -fha_ - 5 * pi / 180, oal);
            Line line6 = new Line(p43_3, p43_4);
            Arc arc6 = fun.DrawArc5(p42, line6, p21);
            Vector2 p46_1 = fun.Polar(p20, pi / -2, 0.1);
            Vector2 p46_2 = fun.Polar(p46_1, fun.CalAngle(p20, p23), oal);
            Vector2 p46 = fun.Inters1(p20, p23, arc6, 1);
            Vector2 p47 = fun.Polar(p33, 0, fun.CalDistance(p32, p43) / 1.5);
            Vector2 p47_1 = fun.Polar(p36, 0, 0.1);
            Vector2 p47_2 = fun.Polar(p47_1, pi / 2 - fha_ * 2, oal);
            Vector2 p47_3 = fun.Polar(p47_1, pi / 2 - fha_, oal);
            Vector2 p48_0 = fun.Polar(p46, pi / 2 + 0.01 * pi / 180, oal);
            Vector2 p48 = fun.Inters1(p46, p48_0, arc5, 0);
            Vector2 p48_1 = fun.Polar(p41, pi / 2, 0.1);
            Vector2 p48_2 = fun.Polar(p48_1, fha_ / -4, oal);
            Line line1 = new Line(p18_1, p18_2);
            Line line2 = new Line(p19_1, p19_2);
            Line line3 = new Line(p20_1, p20_2);
            Line line4 = new Line(p21_1, p21_2);
            Line line7 = new Line(p45_1, p45_2);
            Line line8 = new Line(p46_1, p46_2);
            Line line9 = new Line(p47_1, p47_2);
            Line line10 = new Line(p47_1, p47_3);
            Line line11 = new Line(p48_1, p48_2);
            var polyline1 = Pus.AddPointsToLwPolyLine(p1, p2, p4, p3, p1, p5, p7, p9, p7, p6, p2, p6, p8, p10, p11
            , p12, p14, p18, p16, p15, p17, p13, p11);
            var polyline2 = Pus.AddPointsToLwPolyLine(p23, p22, p24, p35);
            var polyline3 = Pus.AddPointsToLwPolyLine(p30, p25, p26, p38, p39, p41, p39, p38, p27, p28, p29, p30, p31, p32
                , p43, p32, p34, p22, p34, p33, p47, p33, p37, p23, p37, p36, p40, p45, p40, p42);
            Arc arc1 = fun.DrawArc5(p17, line1, p18);
            Arc arc2 = fun.DrawArc5(p19, line2, p13);
            Arc arc3 = fun.DrawArc5(p14, line3, p20);
            Arc arc4 = fun.DrawArc5(p20, line4, p21);
            Arc arc7 = fun.DrawArc5(p41, line7, p44);
            Arc arc8 = fun.DrawArc5(p46, line8, p20);
            Arc arc9 = fun.DrawArc5(p36, line9, p47);
            Arc arc10 = fun.DrawArc5(p47, line10, p43);
            Arc arc11 = fun.DrawArc5(p48, line11, p41);
            
            dxf.AddEntity(new EntityObject[] { polyline1,polyline2 ,polyline3 
            ,arc1 ,arc2,arc3,arc4,arc5,arc6,arc7,arc8,arc9,arc10,arc11
            });
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.PolyFill(dxf, polyline1, 0.5, contour);
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline3, 0.5, contour);
            //标注
            //22_0刀尖
            fun.dimrot1(dxf, p22_0, fun.Polar(p22_0, 0, lu), 180, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LU", "", "");
            fun.dimrot1(dxf, p22_0, p20, 180, dc * 1.5 + p20.Y / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LCF", "", "");
            fun.dimrot1(dxf, p22_0, fun.Polar(p22_0, 0, lpr), 180, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, p22_0, fun.Polar(p22_0, 0, oal), 180, dc * 2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p2, p12, 180, dc * 1.5 + (p12.Y - p2.Y) / 2.0 + p2.Y, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p26, fun .Polar (p26,pi/-2,0.1), 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p1, p2, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p25, p26, 0, dc + ((p11.Y - p25.Y) / 2.0), 2, 1.2 * scale, 1.6 * scale, 0.9, "PL", "", "");
            fun.jdbz2(dxf, new Line(p23, p22), new Line(p24, p22), dc * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        //图F.4  ISYC 301-02-粗柄带颈螺纹切削丝锥
        public static void Coarseshankcuttingtap1(Dictionary<string, Object> data)  //  粗柄带颈螺纹切削丝锥
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层   
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double sl_ = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
            /* double sl_ = 45;
             double scale = 1;            
             double tcl = 10 ;
             double td = 30 ;
             double tcpd = 28 ;
             double thl = 95 ;
             double dn = 24 ;
             double ls = 100 ;
             double oal = 242.5 ;
             double dconms = 40 ;
             double drvl = 33.33;
             double lu = 138;
             double lpr = 154;
             double fha =15;
             double tg = 10;*/
            double tcl = Convert.ToDouble(data["tcl"]);
            double td = Convert.ToDouble(data["td"]);
            double tcpd = Convert.ToDouble(data["tcpd"]);
            double thl = Convert.ToDouble(data["thl"]);
            double dn = Convert.ToDouble(data["dn"]);
            double ls = Convert.ToDouble(data["ls"]);
            double oal = Convert.ToDouble(data["oal"]);
            double dconms = Convert.ToDouble(data["dconms"]);
            double drvl = Convert.ToDouble(data["drvl"]);
            double lu = Convert.ToDouble(data["lu"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double fha = Convert.ToDouble(data["fha"]);
            double tg = Convert.ToDouble(data["tg"]);
            double tg_ = tg * pi / 180;
            double fha_ = fha * pi / 180;
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = fun.Polar(p0, pi, 5);
            Vector2 p0_2 = fun.Polar(p0, 0, oal );
            Vector2 p1 = fun.Polar(p0, pi / 2, tcpd / 2.0);
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 p3 = fun.Polar(p1, tg_ / 2, (thl / 8.0) / Math.Cos(tg_ / 2));
            Vector2 p4 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p5 = fun.Polar(p1, pi / -2, tcpd / 6.0);
            Vector2 p6 = fun.Polar(p3, pi / -2, fun.CalDistance(p3, p4) / 10.0);
            Vector2 p7 = fun.Polar(p2, pi / 2, tcpd / 3.0);
            Vector2 p7_0 = fun.Polar(p7, tg_ / 2, thl);
            Vector2 p8 = fun.Inters(p7, p7_0, p3, p4);           
            Vector2 p9 = fun.Polar(p0, 0, thl);
            Vector2 p10 = fun.Polar(p9, pi / 2, p3.Y);
            Vector2 p11 = fun.mirrorpoint(p10, p0_1, p0_2);
            double q = (p3.Y - p6.Y) / 2.0;//刀齿高度
            Vector2 p12 = fun.Polar(p10, pi / 2,q );
            Vector2 p12_1 = fun.Polar(p8, pi / 2, 0.1 );
            Vector2 p12_2 = fun.Polar(p12_1, fha_, thl);
            Vector2 p13 = fun.Polar(p10, pi / -2, fun.CalDistance(p8, p4)) ;
            Vector2 p15 = fun.Polar(p4, pi / -2, q);
            Vector2 p16 = fun.Polar(p13, pi / -2, q);
            Vector2 p14 = fun.Polar(p8, pi / 2,q );
            Vector2 p14_1 = fun.Polar(p14, pi / 2, 0.1 );
            Vector2 p14_2 = fun.Polar(p14_1, fha_ , thl);
            Vector2 p4_1 = fun.Polar(p4, pi / -2, 0.1 * scale);
            Vector2 p4_2 = fun.Polar(p4_1, fha_, thl);
            Vector2 p15_1 = fun.Polar(p15, pi / -2, 0.1 * scale);
            Vector2 p15_2 = fun.Polar(p15_1, fha_, thl);
            Line line1 = new Line(p14_1, p14_2);
            Arc arc1 = fun.DrawArc5(p12, line1, p14);
            Arc arc2 = fun.DrawArc4(p10, arc1.Radius, p8, 0) ;
            Arc arc3 = fun.DrawArc4(p4, arc2.Radius, p13, 0) ;
            Arc arc4 = fun.DrawArc4(p15, arc1.Radius, p16, 0) ;
            var polyline1 = Pus.AddPointsToLwPolyLine(p5, p6, p3, p1, p2, p4, p8, p7);
            Vector2 p17_0 = fun.Polar(p10, pi / 2 + pi / 4, thl);
            Vector2 p17 = fun.Inters1(p10, p17_0, arc1, 0);
            Vector2 p18_0 = fun.Polar(p17, fun.CalAngle(p17, p10) - pi / 2, thl);
            Vector2 p18 = fun.Inters1(p17, p18_0, arc2, 1);
            Vector2 p19_0 = fun.Polar(p16, 165 * pi / 180, thl);
            Vector2 p19 = fun.Inters1(p16, p19_0, arc3, 1);
            Vector2 p20_0 = fun.Polar(p19, fun.CalAngle(p19, p16) - pi / 2, thl);
            Vector2 p20 = fun.Inters1(p19, p20_0, arc4, 0);
            Vector2 p21_1 = fun.Polar(p12, pi, thl / 4.0);
            Vector2 p21_2 = fun.Polar(p12_1, pi / -2, thl);
            Vector2 p21 = fun.Inters1(p21_1, p21_2, arc1, 1);
            Vector2 p21_3 = fun.Polar(p0, pi / 2, td / 2.0);
            Vector2 p21_4 = fun.Polar(p21_3, 0, thl);
            Line line5 = new Line(p21_3, p21_4);
            Arc arc5 = fun.DrawArc5(p21, line5, p3);
            Vector2 p22 = fun.Polar(p3, fun.CalAngle(p3, p6), fun.CalDistance(p3, p6) / 2.0);
            Vector2 p23_0 = fun.Polar(p22, fun.CalAngle(p3, p21)+1*pi/180, tcl);
            Vector2 p23 = fun.Inters1(p23_0, p22, arc1, 0);
            Arc arc6 = fun.DrawArc4(p23, arc5.Radius, p22, 0);
            Vector2 p24_0 = fun.Polar(p6, fun.CalAngle(p5, p6), thl) ;
            Vector2 p25_0 = fun.Polar(p3, fun.CalAngle(p1, p3), thl);
            var polyline2 = Pus.AddPointsToLwPolyLine(p18, p17, p10, p16, p19, p17, p19, p20);
            var a2c = Pus.ToV2(arc2.Center);//arc2的圆心
            var a3c = Pus.ToV2(arc3.Center);//arc3的圆心
            var z1 = fun.CalAngle(a2c, p18) - fun.CalAngle(a2c, p10);//一个齿的向量            
            double xl1 = fun.CalAngle(a2c, p8) - fun.CalAngle(a2c, p10);//arc2的向量
            double zc1 =( arc2.Radius * 2) * pi;//arc2的满园时的周长
            double zc1_1 = (xl1 / (2 * pi)) * zc1;//arc2弧线的周长
            double zc1_2 = (z1 / (2 * pi)) * zc1;
            int cs1 = (int)(zc1_1 / zc1_2);//arc2弧线上有多少个齿
            double i = 0;
            Vector2 c1 = p18;
            Vector2 c2 = p20;
            Vector2 c4;
            do
            {
                Vector2 c3 = fun.PointRotate(a2c, p17, 2 * pi - z1 * i);
                 c4 = fun.PointRotate(a2c, p18, 2 * pi - z1 * i);
                Vector2 c5 = fun.PointRotate(a3c, p19, 2 * pi + z1 * i);
                Vector2 c6 = fun.PointRotate(a3c, p20, 2 * pi + z1 * i);
                var polyline3 = Pus.AddPointsToLwPolyLine(c4, c3, c1, c2, c5, c3, c5, c6);
                if (i < cs1)
                {
                    polyline3 = Pus.AddPointsToLwPolyLine(c4, c3, c1, c2, c5, c3, c5, c6);
                    fun.PolyFill(dxf, polyline3, 0.5, contour);
                    if (i == cs1 - 1)
                    {
                        polyline3 = Pus.AddPointsToLwPolyLine(c4, c6, p4, p8, c4);
                        fun.PolyFill(dxf, polyline3, 0.5, contour);
                    }
                }
                i++;
                c1 = c4;
                c2 = c6;
            } while (i < cs1);
            var a5c = Pus.ToV2 ( arc5.Center );
            var a6c = Pus.ToV2(arc6.Center );
            var a5x = fun.CalAngle(a5c, p3) - fun.CalAngle(a5c, p21) ;//arc5的向量
            var a5zh = arc5.Radius * 2 * pi;
            var a5d = a5x / (pi * 2) * a5zh;//arc5弧线周长
            Vector2 c4_0 = fun.Polar(c4, pi / 2, thl);
            Vector2 p24 = fun.Inters(c4, c4_0, p6, p24_0);
            Vector2 p25 = fun.Inters(c4, c4_0, p3, p25_0);
            Vector2 p26_0 = fun.Polar(p25, pi / -4, thl);
            Vector2 p26 = fun.Inters1(p25, p26_0, arc6, 0);
            Vector2 p27_0 = fun.Polar(p26, pi / 4, thl);
            Vector2 p27 = fun.Inters1(p26, p27_0, arc5, 1);
            Vector2 p28 = fun.Polar(p26, pi / -2, fun.CalDistance(p25, p24));
            Vector2 p29 = fun.Polar(p27, pi / -2, fun.CalDistance(p25, p24));
            var z2= fun.CalAngle(a5c, p25) - fun.CalAngle(a5c, p27);//一个齿的向量
            var z2d = z2 / (2 * pi) * a5zh;//齿2在arc5中的周长
            int cs2 = (int)(a5d / z2d);
            double n=0;
            double m = fun.CalDistance(p25, p24) ;
            Vector2 d1 = p25;
            Vector2 d4 = p24;
            for (; n< cs2; n++ )
            {
                Vector2 d2 = fun.PointRotate(a5c, p26, z2 * n);
                Vector2 d3 = fun.PointRotate(a5c, p27, z2 * n);              
                Vector2 d6 = fun.Polar(d3, pi / -2, m);
                if (m > 1)
                {
                     d4 = fun.Polar(d1, pi / -2, m);
                    Vector2 d5 = fun.Polar(d2, pi / -2, m);
                     d6 = fun.Polar(d3, pi / -2, m);
                    var polyline5 = Pus.AddPointsToLwPolyLine(d1, d2, d3, d6, d5, d2, d5, d4);
                    fun.PolyFill(dxf, polyline5, 0.5, contour);
                }
                else
                {
                    if (n == cs2 - 1)
                    {
                        Vector2 di_0 = fun.Polar(d1, pi / -4, thl);
                        Vector2 di = fun.Inters1(d1, di_0, arc1, 0);
                        Line lineq1 = new Line(d1, di);
                        fun.drawBline(dxf, lineq1, 0.5, contour);
                    }
                    else
                    {
                        m = 0;
                        d4 = fun.Polar(d1, pi / -2, m);
                        Vector2 d5 = fun.Polar(d2, pi / -2, m);
                        d6 = fun.Polar(d3, pi / -2, m);
                        var polyline5 = Pus.AddPointsToLwPolyLine(d1, d2, d3, d6, d5, d2, d5, d4);
                        fun.PolyFill(dxf, polyline5, 0.5, contour);
                    }
                }
                d1 = d3;
                d4 = d6;
                m -= 0.5/scale ;
            }

            Vector2 p30 = fun.Polar(p11, pi / 2, fun.CalDistance(p3, p6) * (3 / 2.0));
            Vector2 p31_1 = fun.Polar(fun .Polar (p15,pi/-2,td /2.0), 0, (p11.X - p15.X) * (3 / 22.0));
            //Vector2 p31_2 = fun.Polar(p31_1, pi / 2, thl);
            Vector2 p31_2 = new Vector2(p31_1.X, p31_1.Y + thl);
            Vector2 p31 = fun.Inters1(p31_1, p31_2, arc4, 0);
            Vector2 p11_1 = fun.Polar(p0, pi / -2, td / 2.0);
            Vector2 p11_2 = fun.Polar(p11_1, 0, thl);
            Line line6 = new Line(p11_1, p11_2);
            Arc arc7 = fun.DrawArc5(p31, line6, p11);
            Arc arc8 = fun.DrawArc4(p31, arc7.Radius, p30, 0);
            Vector2  a7c = Pus.ToV2(arc7.Center);
            Vector2 p32 = fun.Polar(p11, fun.CalAngle(a7c, p11), fun.CalDistance(p25, p26));
            Vector2 p33 = fun.Polar(p31, fun.CalAngle(a7c, p31), fun.CalDistance(p25, p26));
            Arc arc9 = fun.DrawArc4(p33, arc7.Radius + fun.CalDistance(p25, p26), p32,0);
            Vector2 p34_0 = fun.Polar(p11, -126*pi/180, thl);
            Vector2 p34 = fun.Inters1(p34_0, p11, arc9, 0);
            Vector2 p35_0 = fun.Polar(p34, fun .CalAngle (p34,p11)+pi/2, thl);
            Vector2 p35 = fun.Inters1(p34, p35_0, arc7, 1);
            Vector2 p36 = fun.Polar(p34, pi / 2, fun.CalDistance(p30, p11));
            Vector2 p37 = fun.Polar(p35, pi / 2, fun.CalDistance(p30, p11));
            double z3= fun.CalAngle(a7c, p35) - fun.CalAngle(a7c, p11);//一个齿的向量
            var a7x = fun.CalAngle(a7c, p31) - fun.CalAngle(a7c, p11);//arc7的向量
            var a7zh = arc7.Radius * 2 * pi;
            var a7d = a7x / (pi * 2) * a7zh;//arc7弧线周长
            var z3d = z3 / (2 * pi) * a7zh;//齿2在arc7中的周长
            int cs3 = (int)(a7d / z3d);//齿2在arc7的数量
             i = 0;
            n = fun.CalDistance(p30, p11);
            c1 = p11;
            c4 = p30;
            for (; i < cs3+1; i++)
            {
                if (n > 1)
                {
                    n = n;
                }
              else
                {
                    n = 0;
                }
                c2 = fun.PointRotate(a7c, p34, -z3 * i);
                var c3 = fun.PointRotate(a7c, p35, -z3 * i);
                var c5 = fun.Polar(c2, pi / 2, n);
                var c6 = fun.Polar(c3, pi / 2, n);
                var polyline6= Pus.AddPointsToLwPolyLine(c6, c5, c4, c1, c2, c5, c2, c3);
                if (i == cs3)
                {
                    var c3_0 = fun.Polar(c3, fun.CalAngle(c2, c3), thl);
                    var c3_1 = fun.Inters1(c3, c3_0, arc3, 1);
                     polyline6 = Pus.AddPointsToLwPolyLine(c6, c5, c4, c1, c2, c5, c2, c3_1);
                }
                else
                {                       
                     polyline6 = Pus.AddPointsToLwPolyLine(c6, c5, c4, c1, c2, c5, c2, c3);
                }
                fun.PolyFill(dxf, polyline6, 0.5, contour);
                c4 = c6 ;
                c1 = c3;
                n-=0.5/scale ;
            }
            Vector2 p38_0 = fun.Polar(p11, pi / 4+0.1*pi/180, thl);
            Vector2 p38_1 = fun.Polar(p0, pi / -2-0.1*pi/180, dn/2.0);
            Vector2 p38_2 = fun.Polar(p38_1, 0, thl);
            Vector2 p38_3 = fun.Polar(p10, pi / -4, thl);
            Vector2 p38_4 = fun.Polar(p0, pi / 2, dn / 2.0);
            Vector2 p38_5 = fun.Polar(p38_4, 0, thl);
            Vector2 p38 = fun.Inters(p11, p38_0, p38_1, p38_2);
            Vector2 p39 = fun.Inters(p10, p38_3, p38_4, p38_5);
            Vector2 p40 = fun.Polar(p0, 0, oal);
            Vector2 p41 = fun.Polar(p40, pi / 2, dconms / 2.0);
            Vector2 p42 = fun.Polar(p41, pi, ls);
            Vector2 p43_0 = fun.Polar(p42, pi + pi / 4, thl);
            Vector2 p43 = fun.Inters(p42, p43_0, p38_4, p38_5);
            Vector2 p44 = fun.mirrorpoint(p41, p0_1, p0_2);
            Vector2 p45 = fun.mirrorpoint(p42, p0_1, p0_2);
            Vector2 p46 = fun.mirrorpoint(p43, p0_1, p0_2);
            Vector2 p47 = fun.Polar(p41, pi / -2, dconms / 20.0);
            Vector2 p48 = fun.Polar(p47, pi, drvl);
            Vector2 p49 = fun.Polar(p40, pi / 2, dconms / 15.0);
            Vector2 p50 = fun.Polar(p49, pi, fun.CalDistance(p47, p48));
            Vector2 p51 = fun.mirrorpoint(p47, p0_1, p0_2);
            Vector2 p52 = fun.mirrorpoint(p48, p0_1, p0_2);
            Vector2 p53 = fun.mirrorpoint(p49, p0_1, p0_2);
            Vector2 p54 = fun.mirrorpoint(p50, p0_1, p0_2);
            Arc arc10 = fun.DrawArc5(p30 , new Line(p39, p38), p16);
            var polyline4 = Pus.AddPointsToLwPolyLine(p3, p6, p24, p25,p3);
            var polyline7 = Pus.AddPointsToLwPolyLine(p13,p10,p39,p38,p39,p43,p46,p38,p11,p30,p11,p38,p46,p45,p42,p43,p42,p41,p44,p45);
            var polyline8 = Pus.AddPointsToLwPolyLine(p49, p50, p48, p47, p51, p52, p54, p53);//尾巴部分
            var polyline9 = Pus.AddPointsToLwPolyLine(p47, p50, p48, p49, p53, p52, p54, p51);
            polyline9 .Lineweight = Lineweight.W35;//Lineweight指线宽
            polyline9 .Layer = additionalline;//Layer指图层
           /* dxf.AddEntity(new EntityObject[] { polyline1,polyline2,polyline4 ,polyline7,polyline8 ,polyline9 
            ,arc1,arc2,arc3,arc4,arc5 ,arc6 ,arc7,arc8 ,arc9 
             ,arc10 
            }) ;*/
            fun.PolyFill(dxf, polyline1, 0.5, contour);
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.PolyFill(dxf, polyline7, 0.5, contour);
            fun.PolyFill(dxf, polyline8, 0.5, contour);
            fun.PolyFill(dxf, polyline9, 0.35, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            //局部图
            Vector2 p0_ = fun.Polar(p0, pi / -2, thl * 2);
            Vector2 p0_1_ = fun.Polar(p0_, pi, 5 * 2);
            Vector2 p0_2_ = fun.Polar(p0_, 0, thl * 2.5);
            Vector2 p1_ = fun.Polar(p0_, pi / 2, tcpd / 2.0 * 2);
            Vector2 p2_ = fun.mirrorpoint(p1_, p0_1_, p0_2_);
            Vector2 p3_ = fun.Polar(p1_, tg_ / 2, (thl / 8.0) / Math.Cos(tg_ / 2) * 2);
            Vector2 p4_ = fun.mirrorpoint(p3_, p0_1_, p0_2_);
            Vector2 p5_ = fun.Polar(p1_, pi / -2, tcpd / 6.0 * 2);
            Vector2 p6_ = fun.Polar(p3_, pi / -2, fun.CalDistance(p3_, p4_) / 10.0 );
            Vector2 p7_ = fun.Polar(p2_, pi / 2, tcpd / 3.0 * 2);
            Vector2 p7_0_ = fun.Polar(p7_, tg_ / 2, thl * 2);
            Vector2 p8_ = fun.Inters(p7_, p7_0_, p3_, p4_);
            Vector2 p9_ = fun.Polar(p0_, 0, thl * 2);
            Vector2 p10_ = fun.Polar(p9_, pi / 2, p3.Y * 2);
            Vector2 p11_ = fun.mirrorpoint(p10_, p0_1_, p0_2_);
            double q_ = (p3.Y - p6.Y) / 2.0 * 2;//刀齿高度
            Vector2 p12_ = fun.Polar(p10_, pi / 2, q_);
            Vector2 p12_1_ = fun.Polar(p8_, pi / 2, 0.1 * 2);
            Vector2 p12_2_ = fun.Polar(p12_1_, fha_, thl * 2);
            Vector2 p13_ = fun.Polar(p10_, pi / -2, fun.CalDistance(p8_, p4_) );
            Vector2 p15_ = fun.Polar(p4_, pi / -2, q_);
            Vector2 p16_ = fun.Polar(p13_, pi / -2, q_);
            Vector2 p14_ = fun.Polar(p8_, pi / 2, q_);
            Vector2 p14_1_ = fun.Polar(p14_, pi / 2, 0.1 * 2);
            Vector2 p14_2_ = fun.Polar(p14_1_, fha_, thl * 2);
            Vector2 p4_1_ = fun.Polar(p4_, pi / -2, 0.1 * scale * 2);
            Vector2 p4_2_ = fun.Polar(p4_1_, fha_, thl * 2);
            Vector2 p15_1_ = fun.Polar(p15_, pi / -2, 0.1 * scale * 2);
            Vector2 p15_2_ = fun.Polar(p15_1_, fha_, thl * 2);
            Line line1_ = new Line(p14_1_, p14_2_);
            Arc arc1_ = fun.DrawArc5(p12_, line1_, p14_);
            Arc arc2_ = fun.DrawArc4(p10_, arc1_.Radius, p8_, 0);
            Arc arc3_ = fun.DrawArc4(p4_, arc2_.Radius, p13_, 0);
            Arc arc4_ = fun.DrawArc4(p15_, arc1_.Radius, p16_, 0);
            var polyline1_ = Pus.AddPointsToLwPolyLine(p5_, p6_, p3_, p1_, p2_, p4_, p8_, p7_);
            Vector2 p17_0_ = fun.Polar(p10_, pi / 2 + pi / 4, thl * 2);
            Vector2 p17_ = fun.Inters1(p10_, p17_0_, arc1_, 0);
            Vector2 p18_0_ = fun.Polar(p17_, fun.CalAngle(p17, p10) - pi / 2, thl * 2);
            Vector2 p18_ = fun.Inters1(p17_, p18_0_, arc2_, 1);
            Vector2 p19_0_ = fun.Polar(p16_, 165 * pi / 180, thl * 2);
            Vector2 p19_ = fun.Inters1(p16_, p19_0_, arc3_, 1);
            Vector2 p20_0_ = fun.Polar(p19_, fun.CalAngle(p19_, p16_) - pi / 2, thl * 2);
            Vector2 p20_ = fun.Inters1(p19_, p20_0_, arc4_, 0);
            Vector2 p21_1_ = fun.Polar(p12_, pi, thl / 4.0 * 2);
            Vector2 p21_2_ = fun.Polar(p12_1_, pi / -2, thl * 2);
            Vector2 p21_ = fun.Inters1(p21_1_, p21_2_, arc1_, 1);
            Vector2 p21_3_ = fun.Polar(p0_, pi / 2, td / 2.0 * 2);
            Vector2 p21_4_ = fun.Polar(p21_3_, 0, thl * 2);
            Line line5_ = new Line(p21_3_, p21_4_);
            Arc arc5_ = fun.DrawArc5(p21_, line5_, p3_);
            Vector2 p22_ = fun.Polar(p3_, fun.CalAngle(p3_, p6_), fun.CalDistance(p3_, p6_) / 2.0 );
            Vector2 p23_0_ = fun.Polar(p22_, fun.CalAngle(p3_, p21_) + 1 * pi / 180, tcl * 2);
            Vector2 p23_ = fun.Inters1(p23_0_, p22_, arc1_, 0);
            Arc arc6_ = fun.DrawArc4(p23_, arc5_.Radius, p22_, 0);
            Vector2 p24_0_ = fun.Polar(p6_, fun.CalAngle(p5_, p6_), thl * 2);
            Vector2 p25_0_ = fun.Polar(p3_, fun.CalAngle(p1_, p3_), thl * 2);
            var polyline2_ = Pus.AddPointsToLwPolyLine(p18_, p17_, p10_, p16_, p19_, p17_, p19_, p20_);
            var a2c_ = Pus.ToV2(arc2_.Center);//arc2的圆心
            var a3c_ = Pus.ToV2(arc3_.Center);//arc3的圆心
            var z1_ = fun.CalAngle(a2c_, p18_) - fun.CalAngle(a2c_, p10_);//一个齿的向量            
            double xl1_ = fun.CalAngle(a2c_, p8_) - fun.CalAngle(a2c_, p10_);//arc2的向量
            double zc1_ = (arc2_.Radius * 2) * pi;//arc2的满园时的周长
            double zc1_1_ = (xl1_ / (2 * pi)) * zc1_;//arc2弧线的周长
            double zc1_2_ = (z1_ / (2 * pi)) * zc1_;
            int cs1_ = (int)(zc1_1_ / zc1_2_);//arc2弧线上有多少个齿
            double i_ = 0;
            Vector2 c1_ = p18_;
            Vector2 c2_ = p20_;
            Vector2 c4_;
            do
            {
                Vector2 c3_ = fun.PointRotate(a2c_, p17_, 2 * pi - z1_ * i_);
                c4_ = fun.PointRotate(a2c_, p18_, 2 * pi - z1_ * i_);
                Vector2 c5_ = fun.PointRotate(a3c_, p19_, 2 * pi + z1_ * i_);
                Vector2 c6_ = fun.PointRotate(a3c_, p20_, 2 * pi + z1_ * i_);
                var polyline3_ = Pus.AddPointsToLwPolyLine(c4_, c3_, c1_, c2_, c5_, c3_, c5_, c6_);
                if (i_ < cs1_)
                {
                    polyline3_ = Pus.AddPointsToLwPolyLine(c4_, c3_, c1_, c2_, c5_, c3_, c5_, c6_);
                    fun.PolyFill(dxf, polyline3_, 0.5, contour);
                    if (i_ == cs1_ - 1)
                    {
                        polyline3_ = Pus.AddPointsToLwPolyLine(c4_, c6_, p4_, p8_, c4_);
                        fun.PolyFill(dxf, polyline3_, 0.5, contour);
                    }
                }
                i_++;
                c1_ = c4_;
                c2_ = c6_;
            } while (i_ < cs1_);
            var a5c_ = Pus.ToV2(arc5_.Center);
            var a6c_ = Pus.ToV2(arc6_.Center);
            var a5x_ = fun.CalAngle(a5c_, p3_) - fun.CalAngle(a5c_, p21_);//arc5的向量
            var a5zh_ = arc5_.Radius * 2 * pi;
            var a5d_ = a5x_ / (pi * 2) * a5zh_;//arc5弧线周长
            Vector2 c4_0_ = fun.Polar(c4_, pi / 2, thl * 2);
            Vector2 p24_ = fun.Inters(c4_, c4_0_, p6_, p24_0_);
            Vector2 p25_ = fun.Inters(c4_, c4_0_, p3_, p25_0_);
            Vector2 p26_0_ = fun.Polar(p25_, pi / -4, thl * 2);
            Vector2 p26_ = fun.Inters1(p25_, p26_0_, arc6_, 0);
            Vector2 p27_0_ = fun.Polar(p26_, pi / 4, thl * 2);
            Vector2 p27_ = fun.Inters1(p26_, p27_0_, arc5_, 1);
            Vector2 p28_ = fun.Polar(p26_, pi / -2, fun.CalDistance(p25_, p24_) );
            Vector2 p29_ = fun.Polar(p27_, pi / -2, fun.CalDistance(p25_, p24_) );
            var z2_ = fun.CalAngle(a5c_, p25_) - fun.CalAngle(a5c_, p27_);//一个齿的向量
            var z2d_ = z2_ / (2 * pi) * a5zh_;//齿2在arc5中的周长
            int cs2_ = (int)(a5d_ / z2d_);
            double n_ = 0;
            double m_ = fun.CalDistance(p25_, p24_) ;
            Vector2 d1_ = p25_;
            Vector2 d4_ = p24_;
            for (; n_ < cs2; n_++)
            {
                Vector2 d2_ = fun.PointRotate(a5c_, p26_, z2_ * n_);
                Vector2 d3_ = fun.PointRotate(a5c_, p27_, z2_ * n_);
                Vector2 d6_ = fun.Polar(d3_, pi / -2, m_);
                if (m_ > 1)
                {
                    d4_ = fun.Polar(d1_, pi / -2, m_);
                    Vector2 d5_ = fun.Polar(d2_, pi / -2, m_);
                    d6_ = fun.Polar(d3_, pi / -2, m_);
                    var polyline5_ = Pus.AddPointsToLwPolyLine(d1_, d2_, d3_, d6_, d5_, d2_, d5_, d4_);
                    fun.PolyFill(dxf, polyline5_, 0.5, contour);
                }
                else
                {
                    if (n_ == cs2_ - 1)
                    {
                        Vector2 di_0_ = fun.Polar(d1_, pi / -4, thl * 2);
                        Vector2 di_ = fun.Inters1(d1_, di_0_, arc1_, 0);
                        Line lineq1_ = new Line(d1_, di_);
                        fun.drawBline(dxf, lineq1_, 0.5, contour);
                    }
                    else
                    {
                        m_ = 0;
                        d4_ = fun.Polar(d1_, pi / -2, m_);
                        Vector2 d5_ = fun.Polar(d2_, pi / -2, m_);
                        d6_ = fun.Polar(d3_, pi / -2, m_);
                        var polyline5_ = Pus.AddPointsToLwPolyLine(d1_, d2_, d3_, d6_, d5_, d2_, d5_, d4_);
                        fun.PolyFill(dxf, polyline5_, 0.5, contour);
                    }
                }
                d1_ = d3_;
                d4_ = d6_;
                m_ -= 0.5*2/scale ;
            }
            Vector2 p30_ = fun.Polar(p11_, pi / 2, fun.CalDistance(p3_, p6_) * (3 / 2.0) * 2);
            Vector2 p31_1_ = fun.Polar(fun.Polar(p15_, pi / -2, td / 2.0), 0, (p11_.X - p15_.X) * (3 / 22.0) * 2);
            Vector2 p31_2_ = new Vector2(p31_1_.X, p31_1_.Y + thl);
            Vector2 p31_ = fun.Inters1(p31_1_, p31_2_, arc4_, 0);
            Vector2 p11_1_ = fun.Polar(p0_, pi / -2, td / 2.0 * 2);
            Vector2 p11_2_ = fun.Polar(p11_1_, 0, thl * 2);
            Line line6_ = new Line(p11_1_, p11_2_);
            Arc arc7_ = fun.DrawArc5(p31_, line6_, p11_);
            Arc arc8_ = fun.DrawArc4(p31, arc7_.Radius, p30, 0);
            Vector2 a7c_ = Pus.ToV2(arc7_.Center);
            Vector2 p32_ = fun.Polar(p11_, fun.CalAngle(a7c_, p11_), fun.CalDistance(p25_, p26_) );
            Vector2 p33_ = fun.Polar(p31_, fun.CalAngle(a7c_, p31_), fun.CalDistance(p25_, p26_) );
            Arc arc9_ = fun.DrawArc4(p33_, arc7_.Radius + fun.CalDistance(p25_, p26_), p32_, 0);
            Vector2 p34_0_ = fun.Polar(p11_, -126 * pi / 180, thl * 2);
            Vector2 p34_ = fun.Inters1(p34_0_, p11_, arc9_, 0);
            Vector2 p35_0_ = fun.Polar(p34_, fun.CalAngle(p34_, p11_) + pi / 2, thl * 2);
            Vector2 p35_ = fun.Inters1(p34_, p35_0_, arc7_, 1);
            Vector2 p36_ = fun.Polar(p34_, pi / 2, fun.CalDistance(p30_, p11_));
            Vector2 p37_ = fun.Polar(p35_, pi / 2, fun.CalDistance(p30_, p11_));
            double z3_ = fun.CalAngle(a7c_, p35_) - fun.CalAngle(a7c_, p11_);//一个齿的向量
            var a7x_ = fun.CalAngle(a7c_, p31_) - fun.CalAngle(a7c_, p11_);//arc7的向量
            var a7zh_ = arc7_.Radius * 2 * pi;
            var a7d_ = a7x_ / (pi * 2) * a7zh_;//arc7弧线周长
            var z3d_ = z3_ / (2 * pi) * a7zh_;//齿2在arc7中的周长
            int cs3_ = (int)(a7d_ / z3d_);//齿2在arc7的数量
            i_ = 0;
            n_ = fun.CalDistance(p30_, p11_);
            c1_ = p11_;
            c4_ = p30_;
            for (; i_ < cs3_ + 1; i_++)
            {
                if (n_ > 1)
                {
                    n_ = n_;
                }
                else
                {
                    n_ = 0;
                }
                c2_ = fun.PointRotate(a7c_, p34_, -z3_ * i_);
                var c3_ = fun.PointRotate(a7c_, p35_, -z3_ * i_);
                var c5_ = fun.Polar(c2_, pi / 2, n_);
                var c6_ = fun.Polar(c3_, pi / 2, n_);
                var polyline6_ = Pus.AddPointsToLwPolyLine(c6_, c5_, c4_, c1_, c2_, c5_, c2_, c3_);
                if (i_ == cs3_)
                {
                    var c3_0_ = fun.Polar(c3_, fun.CalAngle(c2_, c3_), thl * 2);
                    var c3_1_ = fun.Inters1(c3_, c3_0_, arc3_, 1);
                    polyline6_ = Pus.AddPointsToLwPolyLine(c6_, c5_, c4_, c1_, c2_, c5_, c2_, c3_1_);
                }
                else
                {
                    polyline6_ = Pus.AddPointsToLwPolyLine(c6_, c5_, c4_, c1_, c2_, c5_, c2_, c3_);
                }
                fun.PolyFill(dxf, polyline6_, 0.5, contour);
                c4_ = c6_;
                c1_ = c3_;
                n_ -= 1.5*2/scale ;
            }
            Vector2 p38_0_ = fun.Polar(p11_, pi / 4+0.1*pi/180, thl * 2);
            Vector2 p38_1_ = fun.Polar(p0_, pi / -2-0.1*pi/180, dn / 2.0 * 2);
            Vector2 p38_2_ = fun.Polar(p38_1_, 0, thl * 2);
            Vector2 p38_3_ = fun.Polar(p10_, pi / -4, thl * 2);
            Vector2 p38_4_ = fun.Polar(p0_, pi / 2, dn / 2.0 * 2);
            Vector2 p38_5_ = fun.Polar(p38_4_, 0, thl * 2);
            Vector2 p38_ = fun.Inters(p11_, p38_0_, p38_1_, p38_2_);
            Vector2 p39_ = fun.Inters(p10_, p38_3_, p38_4_, p38_5_);
            Vector2 p40_ = fun.Polar(p0_, 0, oal * 2);
            Vector2 p41_ = fun.Polar(p40_, pi / 2, dconms / 2.0 * 2);
            Vector2 p42_ = fun.Polar(p41_, pi, ls * 2);
            Vector2 p43_0_ = fun.Polar(p42_, pi + pi / 4, thl * 2);
            Vector2 p43_ = fun.Inters(p42_, p43_0_, p38_4_, p38_5_);
            Vector2 p46_ = fun.mirrorpoint(p43_, p0_1_, p0_2_);
            Arc arc10_ = fun.DrawArc5(p30_, new Line(p39_, p38_), p16_);
            Vector2 p55 = fun.Polar(p0, pi, td * 3.5) ;
            Vector2 p56 = fun.Polar(p55, pi / 2, td);
            Vector2 p57 = fun.Polar(p55, pi / -2, td*1.2);
            Vector2 p58 = fun.Polar(p56, -10*pi/180, td / 9.0);
            Vector2 p71 = fun.Polar(p58, -23 * pi / 180, td * (1.5 / 18.0));
            Vector2 p59 = fun.Polar(p58, -59*pi/180, td*(5.77/18.0));
            Vector2 p60 = fun.Polar(p59, -28*pi/180, td *(17/45.0));
            Vector2 p61 = fun.Polar(p60, -25*pi/180, td *(5.5/18.0));
            Vector2 p62 = fun.Polar(p61, pi / -4, td * (4.8 / 18.0)) ;
            Vector2 p63 = fun.Polar(p62, -74 * pi / 180, td * (7.5 / 18.0));
            Vector2 p64 = fun.Polar(p63, -69 * pi / 180, td * (7 / 18.0));
            Vector2 p65 = fun.Polar(p64, -108 * pi / 180, td * (3.8 / 18.0));
            Vector2 p66 = fun.Polar(p65, -119 * pi / 180, td * (7.63 / 18.0)) ;
            Vector2 p67 = fun.Polar(p66, -142 * pi / 180, td * (3.19 / 18.0));
            Vector2 p68 = fun.Polar(p67, -176 * pi / 180, td * (7.238 / 18.0));
            Vector2 p69 = fun.Polar(p57, pi / 2,-(p57.Y -p65.Y )+ ((p57.Y -p65.Y ) / 10.0));
            Vector2 p70 = fun.Polar(p55, pi / -2, td * (5 / 18.0));
            Vector2 p72 = fun.Polar(p55, pi / 2, td * (5 / 18.0));
            Vector2 p73 = fun.Polar(p55, pi, td * (3 / 18.0));
            Vector2 p74 = fun.Polar(p56, pi / -2, td * (0.84 / 18.0));
            var polyline4_ = Pus.AddPointsToLwPolyLine(p3_, p6_, p24_, p25_, p3_);
            var polyline7_ = Pus.AddPointsToLwPolyLine(p13_, p10_, p39_, p38_, p39_, p43_, p46_, p38_, p11_, p30_, p11_, p38_);
            var polyline8_ = Pus.AddPointsToLwPolyLine(p55, p56, p71, p59, p61, p62, p63, p64, p66, p67, p68, p57, p69, p65, p69, p70, p73, p72, p70, p74, p58) ;
            var polyline9_ = Pus.AddPointsToLwPolyLine(p57, p70, p73, p72, p70, p56);
            polyline8_.Vertexes[1].Bulge = -Math.Tan((66*pi/180) / 4);
            polyline8_.Vertexes[2].Bulge = -Math.Tan((16*pi/180) / 4);
            polyline8_.Vertexes[3].Bulge = Math.Tan((34*pi/180) / 4);
            polyline8_.Vertexes[4].Bulge = -Math.Tan((57*pi/180) / 4);
            polyline8_.Vertexes[5].Bulge = Math.Tan((28*pi/180) / 4);
            polyline8_.Vertexes[6].Bulge = -Math.Tan((7*pi/180) / 4);    
            polyline8_.Vertexes[7].Bulge = -Math.Tan((22*pi/180) / 4);   
            polyline8_.Vertexes[8].Bulge = -Math.Tan((26*pi/180) / 4);   
            polyline8_.Vertexes[9].Bulge = -Math.Tan((52 * pi / 180) / 4);  
            polyline8_.Vertexes[10].Bulge = Math.Tan((49*pi/180) / 4);
            polyline8_.Vertexes[12].Bulge = Math.Tan((22*pi/180) / 4);         
            polyline8_.Vertexes[13].Bulge = -Math.Tan((22*pi/180) / 4);   
            polyline8_.Vertexes[19].Bulge = -Math.Tan((10*pi/180) / 4);
            polyline8_.Lineweight = Lineweight.W35;//Lineweight指线宽   
            polyline8_.Layer = additionalline;//Layer指图层
           /* dxf.AddEntity(new EntityObject[] { polyline1_,polyline2_,polyline4_,polyline7_,polyline8_ ,polyline9_ 
            ,arc1_,arc2_,arc3_,arc4_,arc5_ ,arc6_ ,arc7_,arc8_ ,arc9_
             ,arc10_
            });*/
            fun.PolyFill(dxf, polyline1_, 0.5, contour);
            fun.PolyFill(dxf, polyline2_, 0.5, contour);
            fun.PolyFill(dxf, polyline4_, 0.5, contour);
            fun.PolyFill(dxf, polyline7_, 0.5, contour);
            fun.PolyFill(dxf, polyline8_, 0.5, contour);
            fun.PolyFill(dxf, polyline9_, 0.35, contour);
            fun.drawBArc(dxf, arc10_, 0.5, contour);
            Vector2 v1 = fun.Polar(p1, 0, lu );
            Vector2 v2 = fun.Polar(p0, 0, lpr);
            Vector2 v3 = fun.Polar(p3, pi / 2, 0.1);
            Vector2 v4 = fun.Polar(p11, pi, -z3d*5);
            Vector2 v5 = fun.Polar(v4, pi, -z3d);
            Vector2 v6 = fun.Polar(p15_, 0, tcl );
            Vector2 v7 = fun.Inters1(p0_1, p0_2, arc1, 0);
            Vector2 v7_1 = fun.Polar(v7, fha_, 0.1);
            Vector2 v7_2 = fun.Polar(v7, 0, 0.1);
            Vector2 v8 = fun.Polar(p42, 0, fun.CalDistance(p42, p41) / 2.5);
            Vector2 v9 = fun.Polar(p11, pi , fun.CalDistance(p4, p11) / 20.0);
            Vector2 v10 = fun.Polar(p0, pi + pi / 4, td * 2);
            Vector2 v11 = fun.Polar(p55, pi / -2, td * 1.5);
            Vector2 v12 = fun.Polar(v11, pi / 2, td / 10.0);
            Vector2 v13 = fun.Polar(p73, pi / -2, td * 2);
            Vector2 v14 = fun.Polar(v13, pi / 2, td / 10.0);
            Vector2 v15 = fun.Polar(v6 , pi / -2, td * 2);
            Vector2 v16 = fun.Polar(v6 , pi / -2, td * 1.5);
            Vector2 v17 = fun.Polar(p40, pi / 3, 2*1.7*scale );
            Vector2 v18 = fun.Polar(v17, pi / 3, dconms);
            Vector2 v19 = fun.Polar(v2, pi / 3, 2 * scale * 1.7);
            Vector2 v20 = fun.Polar(v19, pi / 3, dconms/1.5);
            Vector2 v21 = fun.Polar(p0, 75*pi/180, 2 * 1.7 * scale) ;
            Vector2 v22 = fun.Polar(v21, 75 * pi / 180, dconms) ;
            Vector2 v23 = fun.Polar(p4, pi / -6, 2 * 1.7 * scale);
            Vector2 v24 = fun.Polar(v23, pi / -6, dconms / 4.0);
            Vector2 v25 = fun.Polar(p0_, pi / 2 + pi / 6, 2 * 1.7 * scale);
            Vector2 v26 = fun.Polar(v25, pi / 2 + pi / 6, dconms);
            Vector2 v27 = fun.Polar(v6, pi / -4, 1.7 * 2 * scale);
            Vector2 v28 = fun.Polar(v27, pi / -4, dconms / 4.0);
            Vector2 v29 = fun.Polar(p55, pi + pi / 4, 2 * 1.7 * scale);
            Vector2 v30 = fun.Polar(v29, pi + pi / 4, dconms / 2.0);
            Vector2 v31 = fun.Polar(p0, pi / 2, 1.7 * 2 * scale + 1);
            Vector2 v32 = fun.Polar(v31, pi, 1.7 * 2 * scale + 1);
            Vector2 v33 = fun.Polar(p32, pi / -2, (1.7 * 2 * scale + 1) * 2);
            Vector2 v34 = fun.Polar(p33, 0, (1.7 * 2 * scale + 1) * 2);
            Vector2 v35 = fun.Polar(p34, pi / 2, (1.7 * 2 * scale + 1) * 2);

            Vector2 v36 = fun.Polar(v2, pi / 2, dconms);
            Vector2 v37 = fun.Polar(v36, pi / 4, dconms / 4.0);
            Vector2 v38 = fun.Polar(v37, 0, dconms / 2.0);
            Vector2 v39 = fun.mirrorpoint(v36, p0_1, p0_2);
            Vector2 v40 = fun.mirrorpoint(v37, p0_1, p0_2);
            Vector2 v41 = fun.mirrorpoint(v38, p0_1, p0_2);
            fun.dimrot1(dxf, p1, p12, 0, td - ((p12.Y - p1.Y) / 2.0 + p1.Y), 2, 2.2 * scale, 2.6 * scale, 0.9, "THL", "", "");
            fun.dimrot1(dxf, p1,v1 ,0, td*1.3 - ((p1.Y - v1 .Y) / 2.0 + v1 .Y), 2, 2.2 * scale, 2.6 * scale, 0.9, "LU", "", "");
            fun.dimrot1(dxf, p0, v2 , 0, td * 1.6 , 2, 2.2 * scale, 2.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, p0, p40 , 0, td * 1.9, 2, 2.2 * scale, 2.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p42 , p41 , 0, td * 1.3-p41.Y , 2, 2.2 * scale, 2.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p2, p1, 90, td , 2, 2.2 * scale, 2.6 * scale, 0.9, "TCPD", "", "");
            fun.dimrot1(dxf, v3, p15, 90, td * 1.3 + p3.X , 2, 2.2 * scale, 2.6 * scale, 0.9, "TD", "", "");
            fun.dimrot1(dxf, p2, p4, 180, td  - (p4.Y -p2.Y )/2.0+p2.Y , 2, 2.2 * scale, 2.6 * scale, 0.9, "TCL", "", "");
            fun.dimrot1(dxf, p4, v2  , 180, td*1.3 - (p4.Y - p0.Y) / 2.0 , 2, 2.2 * scale, 2.6 * scale, 0.9, "LTA", "", "");
            fun.dimrot1(dxf, p4, p40 , 180, td * 1.6 - (p4.Y - p40.Y) / 2.0, 2, 2.2 * scale, 2.6 * scale, 0.9, "LF", "", "");
            fun.dimrot1(dxf, v4, v5, 180, td  + p4.Y , 2, 2.2 * scale, 2.6 * scale, 0.9, "TP", "", "");
            fun.dimrot1(dxf, p52, p51, 180, td +p52.Y , 2, 2.2 * scale, 2.6 * scale, 0.9, "DRVL", "", "");
            fun.dimrot1(dxf, p41, p44, -90, td , 2, 2.2 * scale, 2.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p1_, p2_, 90, td, 2, 2.2 * scale, 2.6 * scale, 0.9, "TCPD", "", "");
            fun.dimrot1(dxf, p15_, fun .Polar (p3_,pi/2,0.1),90, td*2.5, 2, 2.2 * scale, 2.6 * scale, 0.9, "TD", "", "");
            fun.dimrot1(dxf, p2_ , v6 , 180, td, 2, 2.2 * scale, 2.6 * scale, 0.9, "TCL", "", "");
            fun.jdbz2(dxf, new Line(v7, v7_2 ), new Line(v7, v7_1 ), thl , 2.2 * scale, 2.6 * scale, 0.9, "FHA", "", "");
            //fun.jdbz2(dxf, new Line(p4_, fun.Polar(p4_, tg_/-2, 10)), new Line(p3_, fun .Polar (p3_,tg_/2,10) ),thl*1.5, 2.2 * scale, 2.6 * scale, 0.9, "TG", "", "");
            fun.Axis(dxf, fun.Polar(p40, pi/-3, td * 2), 0, -90, "Z", "X", "Y", 2.2 * scale, 2.6 * scale, 0);
            fun.Axis(dxf, p0, 0, -90, "", "", "", 2 * scale, 2.2 * scale, 0);
            fun.Axis(dxf, p40 , 0, -90, "", "", "", 2 * scale, 2.2 * scale, 0);
            fun.Axis(dxf, v2 , 0, -90, "", "", "", 2 * scale, 2.2 * scale, 0);
            fun.Axis(dxf, p0_  , 0, -90, "", "", "", 2 * scale, 2.2 * scale, 0);
            fun.Axis(dxf, p55 , 0, -90, "", "", "", 2 * scale, 2.2 * scale, 0);
            fun.Singlelinearrow(dxf, "CCMS", v8 , 70, fun.Polar(v8, 70 * pi / 180, dconms / 3), fun.Polar(v8, 70 * pi / 180, dconms / 1.5) , 2.2 * scale, 2.6 * scale);
            fun.Singlelinearrow(dxf, "TDZ", v9 , -45, fun.Polar(v9, -pi / 4, dconms / 2.0), fun.Polar(v9,-pi / 4, dconms ), 2.2 * scale, 2.6 * scale);
            fun.Singlelinearrow(dxf, "FDP",v10 , 180, fun.Polar(v10, 0, dconms / 2.0), fun.Polar(v10, 0 , dconms), 2.2 * scale, 2.6 * scale);
            fun.Singlelinearrow(dxf, "THL", v12, 180, fun.Polar(v12, 0, dconms / 2.0), fun.Polar(v12, 0, dconms), 2.2 * scale, 2.6 * scale);
            fun.Singlelinearrow(dxf, "OAL,LPR", v14, 180, fun.Polar(v14, 0, dconms / 2.0), fun.Polar(v14, 0, dconms), 2.2 * scale, 2.6 * scale);
            fun.Singlelinearrow(dxf, "LF", v16, 180, fun.Polar(v16, 0, dconms / 2.0), fun.Polar(v16, 0, dconms), 2.2 * scale, 2.6 * scale);
            fun.Singlelinearrow(dxf, "LTA", v15, 180, fun.Polar(v15, 0, dconms / 2.0), fun.Polar(v15, 0, dconms), 2.2 * scale, 2.6 * scale);
            Line linev1 = new Line(p55, v11);
            Line linev2 = new Line(p73, v13);
            Line linev3 = new Line(v6 , v15);
            Line linev4 = new Line(v18 , v17);
            Line linev5 = new Line(v19, v20);
            Line linev6 = new Line(v21, v22);
            Line linev7 = new Line(v23, v24);
            Line linev8 = new Line(v25, v26);
            Line linev9 = new Line(v27, v28);
            Line linev10 = new Line(v29, v30);
            var polylinev1 = Pus.AddPointsToLwPolyLine(p32, p33, p34, p35, p32) ;
            var polylinev2 = Pus.AddPointsToLwPolyLine(v41, v40, v39, v36, v37, v38) ;
            polylinev1.Lineweight = Lineweight.W35;//Lineweight指线宽
            polylinev1.Layer = additionalline;//Layer指图层
            polylinev1.LinetypeScale = 5* scale;//指线性比例
            polylinev1.Linetype = Linetype.Dashed ;//Linetype指是点划线还是虚线什么的
            polylinev2.Lineweight = Lineweight.W35;//Lineweight指线宽
            polylinev2.Layer = additionalline;//Layer指图层
            polylinev2.LinetypeScale = 5 * scale;//指线性比例
            polylinev2.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            Text txt1 = new Text("PCS", v18, 2.2 *scale , 0);
            Text txt2 = new Text("MCS", v20, 2.2 * scale, 0);
            Text txt3 = new Text("CIP", v22, 2.2 * scale, 0);
            Text txt4 = new Text("CRP", fun .Polar (v24,pi/-2,2.2*scale ), 2.2*scale, 0);
            Text txt5 = new Text("CIP", v26, 2.2*scale, 0);
            Text txt6 = new Text("CRP", fun.Polar(v28, pi / -2, 2.2 * scale), 2.2*scale, 0) ;
            Text txt7 = new Text("CIP", v30,2.2 *scale, 0);
            Circle circle1 = new Circle(p0, 1.7 * 2 * scale) ;
            Circle circle2 = new Circle(p4, 1.7 * 2 * scale);
            Circle circle3 = new Circle(v6, 1.7 * 2 * scale);
            Circle circle4 = new Circle(p0_ , 1.7 * 2 * scale);
            Line linev11 = new Line(p0_1, p0_2 );
            linev11.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev11.Layer = additionalline;//Layer指图层
            linev11.LinetypeScale = 5 * scale ;//指线性比例
            linev11.Linetype = Linetype.Dashed ;//Linetype指是点划线还是虚线什么的
            Line linev12 = new Line(p0_1_, p0_2_);
            linev12.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev12.Layer = additionalline;//Layer指图层
            linev12.LinetypeScale = 5 * scale;//指线性比例
            linev12.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            Line linev13 = new Line(p55, fun.Polar(p55, 0, dconms*1.3));
            linev13.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev13.Layer = additionalline;//Layer指图层
            linev13.LinetypeScale = 5 * scale;//指线性比例
            linev13.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(new EntityObject[] { linev1, linev2 ,linev3,linev4,linev5 ,linev6,linev7,linev8 ,linev9,linev10 ,linev11,linev12,linev13  
            ,txt1 ,txt2 ,txt3,txt4 ,txt5 ,txt6 ,txt7 ,polylinev1 ,polylinev2
            ,circle1 ,circle2 ,circle3,circle4  
            });


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);

            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}